﻿using BLL;
using ConvertInfo;
using gfVehicleLibraryAJ;
using IYASAKAReport;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using UtilityHelper;
using AJNetDll;
using DBUtility;

namespace IYAKASAPortal.Services
{
    public class UploadNetInfos
    {
        public void StartListen()
        {
            Thread thread = new Thread(new ThreadStart(UploadInfo));
            //thread.Start();
        }

        private void UploadInfo()
        {
             //UploadNetInformation();
            //while (true)
            //{
            //    Thread.Sleep(5000);
            //    UploadNetInformation();
            //}
        }

        #region 联网后，最后上传信息（18C82,18C59,18C62）
        /// <summary>
        /// 得到需要更新的车辆信息
        /// </summary>
        private void UploadNetInformation()
        {
            Networking netWorking = Networking.Instance;

            if (netWorking.bSFLW)
            {
                RESULT_VEHICLE_INFO_BLL info_bll = new RESULT_VEHICLE_INFO_BLL();

                //var vInfo = info_bll.GetModelList(" AJLSH='1801020944010005' ", 1, 2);
                //var vInfo = info_bll.GetModelList(" AJLSH='1801020830010001' and IsUpload='0' and CLXXSJ>'" + DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:01'", "CLXXSJ desc", 1, 2);
                var vInfo = info_bll.GetModelList(" IsUpload='0' and CLXXSJ>'" + DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:01'", "CLXXSJ desc", 1, 2);

                if (vInfo.Length > 0)
                {
                    for (int i = 0; i < vInfo.Length; i++)
                    {
                        UpdateJKInfo(vInfo[i], "18C82");
                        UpdateJKInfo(vInfo[i], "18C59");
                        UpdateJKInfo(vInfo[i], "18C62");
                    }
                }
            }
        }

        /// <summary>
        /// 上传联网信息
        /// </summary>
        /// <param name="strJCLSH"></param>
        public bool UploadNetInformation(string strJCLSH, string strSQQZR)
        {
            bool bRet = false;
            Networking netWorking = Networking.Instance;

            if (netWorking.bSFLW)
            {
                RESULT_VEHICLE_INFO_BLL info_bll = new RESULT_VEHICLE_INFO_BLL();

                var vInfo = info_bll.GetModelList(" IsUpload='0' and JCLSH='" + strJCLSH + "'");
                if (vInfo.Length > 0)
                {
                    for (int i = 0; i < vInfo.Length; i++)
                    {
                        bRet = Upload_18C82(vInfo[0]);
                        if (bRet)
                        {
                            bRet = Upload_18C59(vInfo[0]);
                        }
                        if (bRet)
                        {
                            bRet = Upload_18C62(vInfo[0], strSQQZR);
                        }

                        if (bRet)
                        {
                            DbFactory m_factory = new DbFactory();
                            m_factory.Add("Update RESULT_VEHICLE_INFO set IsUpload='1' where JCLSH='" + strJCLSH + "'");

                            bRet = m_factory.Execute();
                        }
                    }
                }
                else
                {
                    bRet = true;
                }

            }
            else
            {
                bRet = true;
            }

            return bRet;
        }

        /// <summary>
        /// 查询数据库中是否上传接口成功，成功后则不再上传
        /// </summary>
        /// <param name="vInfo"></param>
        /// <param name="strJKID"></param>
        private void UpdateJKInfo(RESULT_VEHICLE_INFO vInfo, string strJKID)
        {
            NET_JK_RESULT_BLL jk_bll = new NET_JK_RESULT_BLL();
            string strSql_Where = "JCLSH='" + vInfo.JCLSH + "' and JKID='" + strJKID + "'";
            var vJk = jk_bll.GetModelList(strSql_Where);
            if (vJk.Length > 0)
            {
                NET_AJ_JK_RESULT_BLL jk_AJ_bll = new NET_AJ_JK_RESULT_BLL();
                string strSqlAJ_Where = "LWLSH='" + vInfo.AJLSH + "' and JKName='" + strJKID + "'";

                var vJk_AJ = jk_AJ_bll.GetModelList(strSqlAJ_Where);

                if (vJk[0].IsSuc != "1" && vJk_AJ.Length < 5)
                {
                    bool b_Ret = false;
                    if (strJKID == "18C82")
                    {
                        b_Ret = Upload_18C82(vInfo);
                    }
                    else if (strJKID == "18C59")
                    {
                        b_Ret = Upload_18C59(vInfo);
                    }
                    else if (strJKID == "18C62")
                    {
                        b_Ret = Upload_18C62(vInfo,"");
                    }

                    if (b_Ret)
                    {
                        vJk[0].IsSuc = "1";
                        vJk[0].HPHM = vInfo.HPHM;
                        vJk[0].LastUpdateTime = DateTime.Now;
                        jk_bll.Update(vJk[0], vJk[0].ID);
                    }
                }
            }
            else
            {
                bool b_Ret = false;
                if (strJKID == "18C82")
                {
                    b_Ret = Upload_18C82(vInfo);
                }
                else if (strJKID == "18C59")
                {
                    b_Ret = Upload_18C59(vInfo);
                }
                else if (strJKID == "18C62")
                {
                    b_Ret = Upload_18C62(vInfo, "");
                }

                NET_JK_RESULT jkInfo = new NET_JK_RESULT();
                jkInfo.IsSuc = b_Ret ? "1" : "0";
                jkInfo.JCLSH = vInfo.JCLSH;
                jkInfo.JKID = strJKID;
                jkInfo.HPHM = vInfo.HPHM;
                jkInfo.LastUpdateTime = DateTime.Now;

                jk_bll.Insert(jkInfo);
            }
        }

        private bool Upload_18C62(RESULT_VEHICLE_INFO info,string strSQQZR)
        {
             bool bRet = false;
             try
             {
                NET_JK_RESULT_BLL jk_bll = new NET_JK_RESULT_BLL();
                var vJKInfo = jk_bll.GetModelList("JCLSH='" + info.JCLSH + "' and JKID='18C62' and IsSuc='1'");
                if(vJKInfo.Length >0)
                {
                    return true;
                }

                 Networking netWorking = Networking.Instance;
                 Vehicle_18C62_Para m_18C62 = new Vehicle_18C62_Para("18C62", netWorking.jkxlh, netWorking.xtlb);
                 m_18C62.jylsh = info.AJLSH;
                 m_18C62.jyjgbh = netWorking.jyjgbh;
                 m_18C62.jcxdh = info.JCXH.HasValue ? info.JCXH.ToString() : "1";
                 m_18C62.jycs = info.JCCS.HasValue ? (int)info.JCCS : 1;
                 m_18C62.hpzl = info.HPZLDH;
                 m_18C62.hphm = info.HPHM.Contains("试") ? "" : info.HPHM;
                 m_18C62.clsbdh = info.VIN;
                 m_18C62.jyjl = info.Z_PD == "1"?"合格":"不合格";
                 m_18C62.pzrxm = strSQQZR;

                 var vRGResult = Get_18C62_RG_Information(info);

                 Dictionary<string, Tuple<string,string,string,string>> dicRGResult= new Dictionary<string,Tuple<string,string,string,string>>();
                 foreach (var v in vRGResult)
                 {
                     if (v.Value.Item4 != "-")
                     {
                         dicRGResult.Add(v.Key, v.Value);
                     }
                 }

                 List<Vehicle_18C62_RG_Para> lstRG = new List<Vehicle_18C62_RG_Para>();
                 var vRGKeys = dicRGResult.Keys.ToList();
                 for (int i = 0; i < dicRGResult.Keys.Count; i++)
                 {
                     Vehicle_18C62_RG_Para m_18C62_RG = new Vehicle_18C62_RG_Para();
                     m_18C62_RG.xh = (i+1).ToString();
                     m_18C62_RG.rgjgpd = dicRGResult[vRGKeys[i]].Item3;
                     m_18C62_RG.rgjybz = "";
                     m_18C62_RG.rgjysm = dicRGResult[vRGKeys[i]].Item4;
                     m_18C62_RG.rgjyxm = dicRGResult[vRGKeys[i]].Item2;
                     lstRG.Add(m_18C62_RG);
                 }
                 m_18C62.RG =lstRG;

                 var vYQResult = Get_18C62_YQ_Information(info);
                 List<Vehicle_18C62_YQ_Para> lstYQ = new List<Vehicle_18C62_YQ_Para>();
                 var vYQKeys = vYQResult.Keys.ToList();
                 for (int i = 0; i < vYQResult.Keys.Count; i++)
                 {
                     Vehicle_18C62_YQ_Para m_18C62_YQ = new Vehicle_18C62_YQ_Para();
                     m_18C62_YQ.xh = (i + 1).ToString();
                     m_18C62_YQ.yqjgpd = vYQResult[vYQKeys[i]].Item5;
                     m_18C62_YQ.yqjyxm = vYQResult[vYQKeys[i]].Item2;
                     m_18C62_YQ.yqjyjg = vYQResult[vYQKeys[i]].Item3;
                     m_18C62_YQ.yqbzxz = vYQResult[vYQKeys[i]].Item4;
                     m_18C62_YQ.yqjybz = vYQResult[vYQKeys[i]].Item7;
                     lstYQ.Add(m_18C62_YQ);
                 }

                 m_18C62.YQ = lstYQ;

                 #region 日志记录
                 LogHelper logHelper = LogHelper.GetSingleLogHelper();

                 string strCategory = LogHelper.LogType.Normal.ToString();
                 LOG_INFO logInfo = new LOG_INFO();
                 logInfo.Category = LogHelper.LogType.Normal.ToString();
                 logInfo.JCLSH = info.JCLSH;
                 logInfo.HostName = System.Net.Dns.GetHostName();
                 logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                 logInfo.LogTime = DateTime.Now;
                 //logInfo.FS_Infor = strXML;
                 logInfo.Log_Infor = "1.调用联网平台前, 18C62";
                 logInfo.OpName = "";
                 logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Normal);
                 logInfo.FunName = "UploadNetInfos.cs->Upload_18C62()";

                 logHelper.WriteLog(logInfo);
                 #endregion

                 #region 填充联网公司接口

                 UploadCondition uploadCondition = new UploadCondition();
                 uploadCondition.m_18C62 = m_18C62;

                 UploadVehicle uploadVehicle = new UploadVehicle();
                 var vRetInfo = uploadVehicle.UploadByJKId(uploadCondition);
                 if (vRetInfo.IsSucessful)
                 {
                     bRet = true;
                     NET_JK_RESULT jkInfo = new NET_JK_RESULT();
                     jkInfo.IsSuc = "1";
                     jkInfo.JCLSH = info.JCLSH;
                     jkInfo.JKID = "18C62";
                     jkInfo.HPHM = info.HPHM;
                     jkInfo.LastUpdateTime = DateTime.Now;
                     jk_bll.Insert(jkInfo);

                     #region 日志记录
                     logHelper = LogHelper.GetSingleLogHelper();

                     strCategory = LogHelper.LogType.NetSuc.ToString();
                     logInfo = new LOG_INFO();
                     logInfo.Category = LogHelper.LogType.NPFail.ToString();
                     logInfo.HostName = System.Net.Dns.GetHostName();
                     logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                     logInfo.LogTime = DateTime.Now;
                     logInfo.Log_Infor = "5.18C62 联网成功," + vRetInfo.Message;
                     logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Normal);

                     logHelper.WriteLog(logInfo);
                     #endregion
                 }
                 else
                 {
                     #region 日志记录
                     logHelper = LogHelper.GetSingleLogHelper();

                     strCategory = LogHelper.LogType.NPFail.ToString();
                     logInfo = new LOG_INFO();
                     logInfo.Category = LogHelper.LogType.NPFail.ToString();
                     logInfo.HostName = System.Net.Dns.GetHostName();
                     logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                     logInfo.LogTime = DateTime.Now;
                     logInfo.Log_Infor = "5.18C62返回页面，联网失败，失败原因：" + vRetInfo.Message;
                     logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Normal);

                     logHelper.WriteLog(logInfo);
                     #endregion
                 }
                 #endregion
             }
             catch (Exception ex)
             {
                 bRet = false;
                 #region 日志记录
                 LogHelper logHelper = LogHelper.GetSingleLogHelper();

                 string strCategory = LogHelper.LogType.Error.ToString();
                 LOG_INFO logInfo = new LOG_INFO();
                 logInfo.Category = LogHelper.LogType.NPFail.ToString();
                 logInfo.HostName = System.Net.Dns.GetHostName();
                 logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                 logInfo.LogTime = DateTime.Now;
                 logInfo.Log_Infor = "5.18C62 转换，联网过程中失败，失败原因：" + ex.Message;
                 logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Error);

                 logHelper.WriteLog(logInfo);
                 #endregion
             }

             return bRet;
        }

        private bool Upload_18C59(RESULT_VEHICLE_INFO info)
        {
            bool bRet = false;
            try
            {
                NET_JK_RESULT_BLL jk_bll = new NET_JK_RESULT_BLL();
                var vJKInfo = jk_bll.GetModelList("JCLSH='" + info.JCLSH + "' and JKID='18C59' and IsSuc='1'");
                if (vJKInfo.Length > 0)
                {
                    return true;
                }

                Networking netWorking = Networking.Instance;
                Vehicle_18C59_Para m_18C59 = new Vehicle_18C59_Para("18C59", netWorking.jkxlh, netWorking.xtlb);
                m_18C59.jylsh = info.AJLSH;
                m_18C59.jyjgbh = netWorking.jyjgbh;
                m_18C59.jcxdh = info.JCXH.HasValue ? info.JCXH.ToString() : "1";
                m_18C59.jycs = info.JCCS.HasValue ? (int)info.JCCS : 1;
                m_18C59.hpzl = info.HPZLDH;
                m_18C59.hphm = info.HPHM.Contains("试") ? "" : info.HPHM;
                m_18C59.clsbdh = info.VIN;
                m_18C59.jssj = DateTime.Now;

                #region 填充联网公司接口
                UploadCondition uploadCondition = new UploadCondition();
                 uploadCondition.m_18C59 = m_18C59;

                 UploadVehicle uploadVehicle = new UploadVehicle();
                 var vRetInfo = uploadVehicle.UploadByJKId(uploadCondition);
                 if (vRetInfo.IsSucessful)
                 {
                     bRet = true;
                     NET_JK_RESULT jkInfo = new NET_JK_RESULT();
                     jkInfo.IsSuc = "1";
                     jkInfo.JCLSH = info.JCLSH;
                     jkInfo.JKID = "18C59";
                     jkInfo.HPHM = info.HPHM;
                     jkInfo.LastUpdateTime = DateTime.Now;
                     jk_bll.Insert(jkInfo);
                     #region 日志记录
                     LogHelper logHelper = LogHelper.GetSingleLogHelper();
                     LOG_INFO logInfo = new LOG_INFO();

                     string strCategory = LogHelper.LogType.NetSuc.ToString();
                     logInfo = new LOG_INFO();
                     logInfo.Category = LogHelper.LogType.NPFail.ToString();
                     logInfo.HostName = System.Net.Dns.GetHostName();
                     logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                     logInfo.LogTime = DateTime.Now;
                     logInfo.Log_Infor = "5.18C59 联网成功," + vRetInfo.Message;
                     logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Normal);

                     logHelper.WriteLog(logInfo);
                     #endregion
                 }
                 else
                 {
                     #region 日志记录
                     LogHelper logHelper = LogHelper.GetSingleLogHelper();
                     LOG_INFO logInfo = new LOG_INFO();

                     string strCategory = LogHelper.LogType.NPFail.ToString();
                     logInfo = new LOG_INFO();
                     logInfo.Category = LogHelper.LogType.NPFail.ToString();
                     logInfo.HostName = System.Net.Dns.GetHostName();
                     logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                     logInfo.LogTime = DateTime.Now;
                     logInfo.Log_Infor = "5.18C59返回页面，联网失败，失败原因：" + vRetInfo.Message;
                     logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Normal);

                     logHelper.WriteLog(logInfo);
                     #endregion
                 }
                #endregion

            }
            catch (Exception ex)
            {
                bRet = false;
                #region 日志记录
                LogHelper logHelper = LogHelper.GetSingleLogHelper();

                string strCategory = LogHelper.LogType.Error.ToString();
                LOG_INFO logInfo = new LOG_INFO();
                logInfo.Category = LogHelper.LogType.NPFail.ToString();
                logInfo.HostName = System.Net.Dns.GetHostName();
                logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                logInfo.LogTime = DateTime.Now;
                logInfo.Log_Infor = "5.18C59 转换，联网过程中失败，失败原因：" + ex.Message;
                logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Error);

                logHelper.WriteLog(logInfo);
                #endregion
            }

            return bRet;
        }

        private bool Upload_18C82(RESULT_VEHICLE_INFO info)
        {
            bool bRet = false;
            try
            {
                NET_JK_RESULT_BLL jk_bll = new NET_JK_RESULT_BLL();
                var vJKInfo = jk_bll.GetModelList("JCLSH='" + info.JCLSH + "' and JKID='18C82' and IsSuc='1'");
                if(vJKInfo.Length >0)
                {
                    return true;
                }

                Networking netWorking = Networking.Instance;
                Vehicle_18C82_Para m_18C82 = new Vehicle_18C82_Para("18C82", netWorking.jkxlh, netWorking.xtlb);
                m_18C82.jylsh = info.AJLSH;
                m_18C82.jyjgbh = netWorking.jyjgbh;
                m_18C82.jcxdh = info.JCXH.HasValue ? info.JCXH.Value.ToString() : "";
                m_18C82.hphm = info.HPHM.Contains("试") ? "" : info.HPHM;
                m_18C82.hpzl = info.HPZLDH;
                m_18C82.clsbdh = info.VIN;
                m_18C82.ycyxm = info.YCY;
                m_18C82.ycysfzh = "";
                Dictionary<string, Tuple<string, string, string, string, string, string>> dicYQInfos = GetYQInformation(info);

                if (dicYQInfos.Keys.Contains("ZCZDLV"))
                {
                    if (string.IsNullOrEmpty(dicYQInfos["ZCZDLV"].Item3) == false)
                    {
                        m_18C82.zczdl = (float)Convert.ToDouble(dicYQInfos["ZCZDLV"].Item3);
                    }

                    if (string.IsNullOrEmpty(dicYQInfos["ZCZDLV"].Item5) == false)
                    {
                        if (Convert.ToInt32(dicYQInfos["ZCZDLV"].Item5) >= 0 && Convert.ToInt32(dicYQInfos["ZCZDLV"].Item5) < 3)
                        {
                            m_18C82.zczdpd = dicYQInfos["ZCZDLV"].Item5;
                        }
                    }

                    if (string.IsNullOrEmpty(dicYQInfos["ZCZDLV"].Item6) == false)
                    {
                        m_18C82.zdjccs = Convert.ToInt32(dicYQInfos["ZCZDLV"].Item6);
                    }
                }

                if (info.JCLSH.Contains("G"))
                {//挂车
                    //RESULT_VEHICLE_INFO vRet = Login.LoginHelper.GetGLCInfoByJCLSH(info.JCLSH);
                    //if (vRet != null && string.IsNullOrEmpty(vRet.JCLSH) == false)
                    //{
                    //    RESULT_BRAKE_BLL brake_bll = new RESULT_BRAKE_BLL();
                    //    var vBrake = brake_bll.GetModel(vRet.JCLSH);
                    //    if (string.IsNullOrEmpty(vBrake.ZCZDLV_PD) == false && vBrake.ZCZDLV_PD == "1")
                    //    {
                    //        m_18C82.zczdjyjg = "1";
                    //    }
                    //    else
                    //    {
                    //        m_18C82.zczdjyjg = "0"; 
                    //    }
                    //}
                    //else
                    //{
                    //    m_18C82.zczdjyjg = "0"; 
                    //}
                }
                else
                {//不适用
                    m_18C82.zczdjyjg = "0"; 
                }

                m_18C82.zczdjyjg = "0";
                m_18C82.zcpd = info.Z_PD;
                if (info.JCCS.HasValue)
                {
                    m_18C82.zjccs = (int)info.JCCS;
                }
                else
                {
                    m_18C82.zjccs = 1;
                }

                if (dicYQInfos.Keys.Contains("SCZBZL"))
                {
                    var vLoginInfo = Login.LoginHelper.GetLoginInfo(info.HPHM, info.HPZLDH);
                    if (string.IsNullOrEmpty(dicYQInfos["SCZBZL"].Item3) == false)
                    {
                        m_18C82.jczczbzl = Convert.ToInt32(dicYQInfos["SCZBZL"].Item3);
                        m_18C82.zbzlpd = dicYQInfos["SCZBZL"].Item5;

                        if (string.IsNullOrEmpty(vLoginInfo.ZBZL) == false)
                        {
                            m_18C82.bzzczbzl = Convert.ToInt32(info.ZBZL);
                        }
                        else
                        {
                            m_18C82.bzzczbzl = null;
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(vLoginInfo.ZBZL) == false)
                        {
                            m_18C82.bzzczbzl = Convert.ToInt32(info.ZBZL);
                        }
                        m_18C82.jczczbzl = null;
                        m_18C82.zbzlpd = null;
                    }
                }
                else
                {
                    m_18C82.jczczbzl = null;
                    m_18C82.zbzlpd = null;
                    var vLoginInfo = Login.LoginHelper.GetLoginInfo(info.HPHM, info.HPZLDH);
                    if (string.IsNullOrEmpty(vLoginInfo.ZBZL) == false)
                    {
                        m_18C82.bzzczbzl = Convert.ToInt32(info.ZBZL);
                    }
                    else
                    {
                        m_18C82.bzzczbzl = null;
                    }
                }

                if (m_18C82.bzzczbzl.HasValue && m_18C82.jczczbzl.HasValue)
                {
                    int iAbs = Math.Abs((int)m_18C82.jczczbzl - (int)m_18C82.bzzczbzl);
                    m_18C82.zczbzlbfb = (float)(iAbs / Convert.ToInt32(m_18C82.bzzczbzl));
                }
                else
                {
                    m_18C82.zczbzlbfb = null;
                }

                #region 填充联网公司接口
                UploadCondition uploadCondition = new UploadCondition();
                 uploadCondition.m_18C82 = m_18C82;

                 UploadVehicle uploadVehicle = new UploadVehicle();
                 var vRetInfo = uploadVehicle.UploadByJKId(uploadCondition);
                 if (vRetInfo.IsSucessful)
                 {
                    bRet = true;

                    NET_JK_RESULT jkInfo = new NET_JK_RESULT();
                    jkInfo.IsSuc = "1";
                    jkInfo.JCLSH = info.JCLSH;
                    jkInfo.JKID = "18C82";
                    jkInfo.HPHM = info.HPHM;
                    jkInfo.LastUpdateTime = DateTime.Now;
                    jk_bll.Insert(jkInfo);

                    #region 日志记录
                    LogHelper logHelper = LogHelper.GetSingleLogHelper();
                    LOG_INFO logInfo = new LOG_INFO();

                    string strCategory = LogHelper.LogType.NPFail.ToString();
                    logInfo = new LOG_INFO();
                    logInfo.Category = LogHelper.LogType.NPFail.ToString();
                    logInfo.HostName = System.Net.Dns.GetHostName();
                    logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                    logInfo.LogTime = DateTime.Now;
                    logInfo.Log_Infor = "5.18C82 联网成功," + vRetInfo.Message;
                    logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Normal);

                    logHelper.WriteLog(logInfo);
                    #endregion
                }
                else
                {
                    #region 日志记录
                    LogHelper logHelper = LogHelper.GetSingleLogHelper();
                    LOG_INFO logInfo = new LOG_INFO();

                    string strCategory = LogHelper.LogType.NPFail.ToString();
                    logInfo = new LOG_INFO();
                    logInfo.Category = LogHelper.LogType.NPFail.ToString();
                    logInfo.HostName = System.Net.Dns.GetHostName();
                    logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                    logInfo.LogTime = DateTime.Now;
                    logInfo.Log_Infor = "5.18C82返回页面，联网失败，失败原因：" + vRetInfo.Message;
                    logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Normal);

                    logHelper.WriteLog(logInfo);
                    #endregion
                }
                #endregion

            }
            catch (Exception ex)
            {
                #region 日志记录
                LogHelper logHelper = LogHelper.GetSingleLogHelper();

                string strCategory = LogHelper.LogType.Error.ToString();
                LOG_INFO logInfo = new LOG_INFO();
                logInfo.Category = LogHelper.LogType.NPFail.ToString();
                logInfo.HostName = System.Net.Dns.GetHostName();
                logInfo.IPAddress = logHelper.GetIPAddress(logInfo.HostName);
                logInfo.LogTime = DateTime.Now;
                logInfo.Log_Infor = "5.18C82 转换，联网过程中失败，失败原因：" + ex.Message;
                logInfo.Name = logHelper.GetLogName(LogHelper.LogType.Error);

                logHelper.WriteLog(logInfo);
                #endregion
            }
            return bRet;
        }

        /// <summary>
        /// 得到报告单中仪器的结果，标准，判定
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private Dictionary<string, Tuple<string, string, string, string, string, string>> GetYQInformation(RESULT_VEHICLE_INFO info)
        {
            AJReport m_AjReport = new AJReport(info, false);
            rpt.DsAJ ds = new rpt.DsAJ();

            Dictionary<string, Tuple<string, string, string, string, string, string>> dicInfo_18C82;
            Dictionary<string, Tuple<string, string, string, string, string, string,string>> dicInfo_18C62;
            m_AjReport.GetDataTableReport_YQ(ds, out dicInfo_18C82, out dicInfo_18C62);

            return dicInfo_18C82;
        }

        private Dictionary<string, Tuple<string, string, string, string, string,string,string>> Get_18C62_YQ_Information(RESULT_VEHICLE_INFO info)
        {
            AJReport m_AjReport = new AJReport(info, false);
            rpt.DsAJ ds = new rpt.DsAJ();

            m_AjReport.bShowWKCCAndZBZL = false;

            //是否显示外廓尺寸和整备质量
            CONST_DEFINE_WEB_BLL category_bll = new CONST_DEFINE_WEB_BLL();
            var vZBZL = category_bll.GetModelList("CategoryId='17'");
            if (vZBZL.Length > 0)
            {
                if (vZBZL[0].Code == "1")
                {
                    m_AjReport.bShowWKCCAndZBZL = true;
                }
            }

            Dictionary<string, Tuple<string, string, string, string, string, string>> dicInfo_18C82;
            Dictionary<string, Tuple<string, string, string, string, string, string,string>> dicInfo_18C62;
            m_AjReport.GetDataTableReport_YQ(ds, out dicInfo_18C82, out dicInfo_18C62);

            return dicInfo_18C62;
        }

        /// <summary>
        /// 得到报告单中人工的结果
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private Dictionary<string, Tuple<string, string, string, string>> Get_18C62_RG_Information(RESULT_VEHICLE_INFO info)
        {
            Dictionary<string, Tuple<string, string, string, string>> dicRGInfos;
            AJReport m_AjReport = new AJReport(info, false);
            rpt.DsAJ ds = new rpt.DsAJ();
            m_AjReport.GetDataTableReport_RG(ds.Tables["dtRG"], out dicRGInfos);

            return dicRGInfos;
        }

      
        #endregion
    }
}